<?php 
  $link=mysql_connect("localhost","root","1234");//เชื่อมต่อฐานข้อมูล
  $chk = 'create database it341_db2';//สร้างฐานข้อมูล
  mysql_query($chk,$link);//เรียกใช้คำสั่งฐานข้อมูล
  mysql_select_db("it341_db2",$link);//เลือกฐานข้อมูล
  
  
  $create_customer = "create table customer(
  		id int primary key,
  		name varchar(255),
  		type varchar(255),
  		address varchar(255))";
  mysql_query($create_customer,$link);
  
  
  $create_shop = "create table shop(
  		id int primary key,
  		name varchar(255),
  		address varchar(255))";
  mysql_query($create_shop,$link);
  
  
$create_product = "create table product(
		id int primary key,
		type varchar(255),
		name varchar(255),
		price int,
		discount int,
		special varchar(255))";

mysql_query($create_product,$link);


$create_order = "create table orders(
		id int primary key,
		pid int,
		qty int,
		foreign key (pid) references product(id))";
mysql_query($create_order,$link);

mysql_close($link);

?>